
{extend name='public/base' /}

{block name="content"}

<div class="layui-col-md12">

    <div class="layui-card">
        <div class="layui-card-body">
            <form action="" class="layui-form" method="get">
<!--                <div class="layui-col-md12"  style="display: flex;font-size:24px;align-items: center;justify-content: space-between;padding: 20px 0">-->
<!--                    <div class="layui-col-md4 " style="border-right: 1px solid gray">-->
<!--                        <div style="text-align: center">商户数</div>-->
<!--                        <div style="text-align: center;margin-top: 10px">{$info.merchant_sum}</div>-->
<!--                    </div>-->
<!--                    <div class="layui-col-md4 " style="border-right: 1px solid gray">-->
<!--                        <div style="text-align: center">今日已上报</div>-->
<!--                        <div style="text-align: center;margin-top: 10px">{$info.report}</div>-->
<!--                    </div>-->
<!--                    <div  class="layui-col-md4 " style="" onclick="list()">-->
<!--                        <div style="text-align: center">今日未上报</div>-->
<!--                        <div style="text-align: center;margin-top: 10px">{$info.no_report}</div>-->
<!--                    </div>-->
<!--                </div>-->
                <div class="layui-form-item layui-form-pane">
                    <div class="layui-inline">
                        <label class="layui-form-label">任务类型：</label>
                        <div class="layui-input-inline">
                            <select name="type" >
                                <option value="0" >请选择</option>
                                <option value="1" >三关一闭</option>
                                <option value="2" >餐饮油水分离器</option>
                                <option value="3" >商户消杀</option>
                                <option value="4" >油烟管道清洗</option>
                                <option value="5" >餐饮厨自灭</option>
                                <option value="6" >燃气报警器</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">状态：</label>
                        <div class="layui-input-inline">
                            <select name="status" >
                                <option value="-1" >请选择</option>
                                <option value="0" >待审核</option>
                                <option value="1" >审核成功</option>
                                <option value="2" >审核失败</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">选择时间：</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="create_time" id="create_time" placeholder="">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn icon-btn layui-btn-sm" data-id="table_id" lay-filter="search" lay-submit="">
                            <i class="layui-icon"></i>搜索
                        </button>
                        <button type="reset" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i class="layui-icon layui-icon-refresh"></i>{:__('Reset')}</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" id="table_id" lay-filter="table_id"></table>
        </div>
    </div>

</div>
{/block}

{block name="js"} <!--js处理区-->
<script type="text/html" id="toolbarDemo">

</script>

<script type="text/html" id="operationTpl">



    {{# if(d.status==0){ }}
    <a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-xs {:node('Cost/costEdit')}" data-title="审核" lay-event="noRecord"><i class="layui-icon">&#xe679;</i></a>
    {{# } }}

    {{# if(d.status>0){ }}
    <a href="javascript:;" class="layui-btn  layui-btn-primary layui-btn-xs {:node('Cost/detail')}" data-title="查看" lay-event="detail"><i class="layui-icon">&#xe705;</i></a>
    {{# } }}
    {{# if(d.fail_count>0){ }}
    <a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-xs {:node('Merchant/add')}" data-title="失败记录" lay-event="taskFail"><i class="layui-icon">&#xe642;</i></a>
    {{#}}}
</script>

<script>
    layui.use(['element', 'table', 'form', 'jquery', 'lucky','opTable','laydate'], function () {
        var element = layui.element;
        var form = layui.form;
        var table = layui.table;
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var lucky=layui.lucky;
        var opTable = layui.opTable;
        form.render();
        laydate.render({
            elem: '#create_time'
            ,type: 'date',
            range:'~',
            trigger: 'click'
        });
        var myTables = table.render({
            elem: '#table_id',
            url:"{:url('index')}",
            where: { info_type: 2}, //开启头部工具栏，并为其绑定左侧模板
            defaultToolbar: ['filter', 'exports', 'print'],
            toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
            even: true, //开启隔行背景
            id:'table_id',
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip','last'] //自定义分页布局
                ,groups: 5 //只显示 1 个连续页码
                ,first: false //不显示首页
                ,last: false //不显示尾页
                ,limit:20
                ,limits:[10,20,30,50]
            },
            // height: 'full-100',100',
            text: {
                none: '暂无相关数据'
            },
            cols: [[
                // { title: '', type: 'checkbox', fixed: true},
                { title: 'id',field: 'id'},
                { title: '类型',field: 'type',templet:function (item){
                        return item.task.name
                    }},
                { title: '商户',field: 'merchant_name',width:'10%'},
                { title: '提交电话',field: 'merchant',templet:function (item){
                    return item.merchant.mobile;
                    }},
                { title: '提交时间',field: 'create_tiem',templet:function (item){
                        return   layui.util.toDateString((item.create_time)*1000)
                    }},
                { title: '状态',field: 'status',templet:function (item){
                        var status = item.status
                        if ( status== 0){
                            return '待审核'
                        } else if (status == 1){
                            return '审核成功'
                        } else if (status == 2){
                            return '审核失败'
                        }
                    }},
                { title: '审核人',field: 'suggest_name'},
                { title: '审核时间',field: 'suggest_time',templet:function (item){
                    if(item.suggest_time!=null){
                        return   layui.util.toDateString((item.suggest_time)*1000)
                    }else {
                        return '';
                    }

                    }},
                {templet: '#operationTpl', width: 200,align: 'center', title: '操作'}
            ]],
            //  展开的列配置
            openCols: [
                {field: 'desc', title: '描述信息'}
            ],
            done: function (res) {
                layer.closeAll('loading');
            }
        });


        /**
         * 监听单行工具操作
         */
        table.on('tool(table_id)', function (obj) {
            var data = obj.data;
            var _id=parseInt(data.id);
            var layEvent = obj.event;
            if(layEvent==="detail"){
                lucky.CreateOpenForm("详情","{:url('detail')}?id=" + _id);
                return false;
            }else if(layEvent==="noRecord"){
                lucky.CreateOpenForm("详情","{:url('detail')}?id=" + _id);
                return false;
            } if(layEvent==="taskFail"){
                lucky.CreateOpenForm("审核失败记录","{:url('taskFail')}?id=" + _id);
                return false;
            }
        });
        table.on('toolbar(table_id)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            if(obj.event==="add"){
                lucky.CreateOpenForm("生成费用单","{:url('add')}");
                return false;
                // adminAdd
            } else if(obj.event==="adminAdd"){
                lucky.CreateOpenForm("添加人工缴费用","{:url('adminAdd')}");
                return false;
            }else if(obj.event==="close"){
                opTables.closeAll();
            }else if(obj.event==="open"){
                opTables.openAll();
            }else if(obj.event==="detail"){
                lucky.CreateOpenForm("订单详情","{:url('detail')}");
                return false;
            }else if(obj.event==="reload"){
                lucky.CreateReload();
            }else if(obj.event==="del"){
                var num=0;
                var id=[];
                for (var i in data) {
                    num++;
                    id.push(data[i].id);
                }
                if (num<1) {
                    layer.msg("请选择一项",{time:1500});return false;
                }
                lucky.FormatData(id,"{:url('del')}");
                return  false;
            }
        });

        /**
         * 关键词搜索树
         */
        form.on('submit(search)', function (obj) {
            lucky.CreateSearch(obj.field);
            return false;
        });
        /**
         *跳转商户列表
         */
        list=function (){
            lucky.CreateOpenForm("未上报商户列表","{:url('NoReport/index')}");
            return false;
        };
    });

</script >

{/block}
